<div class="main layui-clear">
    <div class="wrap">
        <div class="content detail">
            <div class="fly-panel detail-box">
                <h1>
                   <?php echo $question['title'] ?>
                </h1>
                <div class="fly-tip fly-detail-hint">
                    <span>
                        <?php echo $question['status'] ?>
                    </span>
                    <div class="jie-admin-box" data-id="8828">
                    </div>
                    <div class="fly-list-hint">
                        <a href="#comment">
                            <i class="iconfont" title="回答">
                                
                            </i>
                            <?php echo $question['answer_num']; ?>
                        </a>
                        <i class="iconfont" title="人气">
                            
                        </i>
                       <?php echo $question['view_num'] ?>
                    </div>
                </div>
                <div class="detail-about">
                    <a class="jie-user" href="{:U('home/u/index')}">
                        <img src="__ROOT__/<?php echo $user['face'] ?>"
                        alt=" <?php echo $user['nickname'] ?>">
                        <cite>
                           <?php echo $user['nickname'] ?>
                            <em>
                             <?php echo CT($question['create_time']) ?>
                            </em>
                        </cite>
                    </a>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="8828">
                        <span style="color:#FF7200">
                            悬赏：<?php echo $question['kiss_num'] ?>飞吻
                        </span>
                        <?php if ($_SESSION['id']==$question['uid']) { ?>
                            
                        <span class="layui-btn layui-btn-mini jie-admin" type="edit">
                            <a href="{:U('home/jie/edit',array('id'=>$question['id']))}">
                                编辑此贴
                            </a>
                            <?php }  ?>
                        </span>

                        <?php if ($store==1) { ?>
                             <span class="layui-btn layui-btn-mini jie-admin layui-btn-danger store " type="collect" data-type="add" qid="<?php echo $question['id'] ?>">取消收藏
                        </span>
                       <?php } ?>
                        <?php if ($store==0) { ?>
                        <span class="layui-btn layui-btn-mini jie-admin store " type="collect" data-type="add" qid="<?php echo $question['id'] ?>">
                            收藏
                        </span>
                        <?php } ?>
                       
                    </div>
                </div>
                <div class="detail-body photos">
                    <?php echo htmlspecialchars_decode( $question['content']) ?>
                </div>
            </div>
            <div class="fly-panel" style="height: 90px;">
                <script type="text/javascript">
                    /*728*90 创建于 2017/3/17*/
                    var cpro_id = "u2927108";
                </script>
                <script type="text/javascript" src="http://cpro.baidustatic.com/cpro/ui/c.js">
                </script>
            </div>
            <div class="fly-panel detail-box" style="padding-top: 0;">
                <ul class="jieda photos" id="jieda">
                
            <?php foreach ($answer as $v) { ?>

            <!-- 列表开始 -->
               
                    <li data-id="30252">
                        <a name="item-1490925883096">
                        </a>
                        <div class="detail-about detail-about-reply">
                            <a class="jie-user" href="{:U('home/u/main',array('id'=>$v['uid']))}">
                                <img src="__ROOT__/<?php echo $v['face']; ?>"
                                alt="黯隗、" layer-index="0">
                                <cite>
                                    <i>
                                        <?php echo $v['nickname'] ?>
                                    </i>
                                </cite>
                            </a>
                            <div class="detail-hits">
                                <span>
                                   <?php echo CT($v['create_time']) ?>
                                </span>
                            </div>
                        </div>
                        <div class="detail-body jieda-body">
                            <?php echo xbs(htmlspecialchars_decode($v['content'])) ?>
                        </div>
                        <div class="jieda-reply">
                            
                            <?php if ($v['is_zan']) { ?>
                             <span class="jieda-zan " type="zan">
                                
                                <i class="iconfont icon-zan zanok zan" aid= "<?php  echo $v['id'] ?>">
                                </i>
                                <em>
                                   <?php echo $v['zan_num'] ?>
                                   
                                </em>
                            </span>
                           <?php }else{ ?>
                            <span class="jieda-zan " type="zan">
                                
                                <i class="iconfont icon-zan zan" aid= "<?php  echo $v['id'] ?>">
                                </i>
                                <em>
                                   <?php echo $v['zan_num'] ?>
                                   
                                </em>
                            </span>
                           <?php } ?>

                            <span type="reply" class="reply" nickname="<?php echo $v['nickname'] ?>">
                                <i class="iconfont icon-svgmoban53">
                                </i>
                                回复
                            </span>
                           <div class="jieda-admin status" aid="<?php echo $v['id'] ?>" >

                            <?php if ($question['uid']==$_SESSION['id']) { ?>
                               
                           
                            <?php if ($question['status']=="未结贴") {  ?>
                               
                               
                               <?php if ($v['status']=="0"&&$v['uid']!=$_SESSION['id']) {  ?>
                                <span class="jieda-accept" type="accept" >
                                    采纳
                                </span>
                            <?php } ?>
                            <?php } ?>
                            <?php  }  ?>
                             <?php if ($v['status']=="1") {  ?>
                                 <i class="iconfont icon-caina" title="最佳答案"></i>
                            <?php } ?>
                            
                          
                            </div>
                         
                           
                        </div>
                    </li>

                
                 <?php } ?>
                 </ul>
                <!-- 列表结束 -->
                <div class="layui-form layui-form-pane">
                    <form action="/jie/reply/" method="post">
                        <div class="layui-form-item layui-form-text">
                            <a name="comment">
                            </a>
                            <div class="layui-input-block">
                                
                                <textarea id="L_content" name="content"
                                placeholder="" class="layui-textarea fly-editor" style="height: 150px;">
                                </textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <input name="qid" value="<?php echo $question['id']  ?>" type="hidden">
                            <button class="layui-btn" lay-filter="add" lay-submit="">
                                提交回答
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="edge">
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                最近热帖
            </dt>
              
                <?php foreach ($hotView as $v) { ?>
                   
                        <dd>
                <a href="{:U('home/jie/index',array('id'=>$v['id']))}">
                    <?php echo $v['title'] ?>
                </a>
                <span>
                    <i class="iconfont">
                        
                    </i>
                   
                    <?php echo $v['view_num'] ?>
                <span>
            </dd>
                 <?php } ?>

            <dd>
        </dl>
     
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                近期热议
            </dt>

            <?php foreach ($hotAnswer as $v) { ?>
               
          
            <dd>
                <a href="{:U('home/jie/index',array('id'=>$v['id']))}">
                 <?php echo $v['title'] ?>
                </a>
                <span>
                    <i class="iconfont">
                        
                    </i>
                    <?php echo $v['answer_num'] ?>
                </span>
            </dd>
             <?php } ?>
        </dl>
        <div class="fly-panel">
            <script type="text/javascript">
                /*336*280*/
                var cpro_id = "u2482656";
            </script>
            <script type="text/javascript" src="http://cpro.baidustatic.com/cpro/ui/c.js">
            </script>
        </div>
    </div>
</div>

<script type="text/javascript">
            layui.use(['form', 'jquery','layedit'], function(){
                  var form = layui.form()
                  ,layer = layui.layer,
                   $ = layui.jquery;
                     layedit = layui.layedit;
                   //富文本编辑器
					layedit.set({
					  uploadImage: {
					    url: '{:U('home/jie/uploadImage')}' //接口url
					    ,type: '' //默认post
					  }
					});    

				   index=layedit.build('L_content', {
				      height: 180 //设置编辑器高度
				    });
					          

                  //监听提交
                  form.on('submit(add)', function(data){
                       content = layedit.getContent(index);
                       // alert(content.length);
					                
				        if(content.length<20){
				           layer.msg("内容不低于20", function(){}
				                );
				           return false;
				        }
				        	// console.log(data);
				          data.field.content = content;
				          console.log(data);

                       $.ajax({
                            url: '{:U('home/jie/answerAdd')}',
                            type: 'POST',
                            dataType: 'json',
                            data: data.field,
                        })
                        .done(function(respones) {

                            // console.log(respones);
                           if (respones.error==1) {
                                layer.msg(respones.info, {icon: 5},function(){});
                           }else{
                                
                                 layer.alert(respones.info, {icon: 6},function(){
                                    location.replace(respones.url)
                                 });
                           };
                        })
                        .fail(function() {
                            console.log("error");
                        })
                         return false;
                        
                 });

            //收藏的
            $('.store').click(function(date) {
                qid = $(this).attr('qid');
                obj= $(this);

                $.ajax({
                    url: '{:U('home/jie/store')}',
                    type: 'POST',
                    dataType: 'json',
                    data: {qid: qid},
                })
                .done(function(respones) {
                     if (respones.error==2) {
                                layer.msg(respones.info, {icon: 5},function(){});
                                obj.html("取消收藏");
                                obj.addClass('layui-btn-danger');
                           }else if(respones.error==3){
                                
                                 layer.msg(respones.info, {icon: 5},function(){});
                                obj.html("收藏");
                                obj.removeClass('layui-btn-danger');
                           }else if(respones.error==1){
                                layer.msg(respones.info, {icon: 5},function(){});
                           };
                })
                .fail(function() {
                    console.log("error");
                })
              
                
            });
                //采纳和未结帖的
                $('.status').click(function(data) {
                        status = $(this).attr('aid');
                        obj = $(this);
                        $.ajax({
                            url: '{:U('home/jie/status')}',
                            type: 'post',
                            dataType: 'json',
                            data: {status: status},
                        })
                        .done(function(respones) {
                            if (respones.error==1) {
                                layer.msg(respones.info, {icon: 6},function(){
                                    location.replace(respones.url)
                                });
                                // obj.html("<i class='iconfont icon-caina' title='最佳答案'></i>")
                            }else{
                                layer.msg(respones.info, {icon: 5},function(){});

                            };
                        })
                        .fail(function() {
                            console.log("error");
                        })
                        
                        
                });

            //点赞
            
                $('.zan').click(function(date) {
                aid = $(this).attr('aid');
                obj= $(this);

                $.ajax({
                    url: '{:U('home/jie/zan')}',
                    type: 'POST',
                    dataType: 'json',
                    data: {aid: aid},
                })
                .done(function(respones) {
                     if (respones.error==2) {
                                layer.msg(respones.info, {icon: 6},function(){});
                                // obj.html("取消点赞");
                                obj.addClass('zanok');
                                num = parseInt(obj.siblings('em').html())+1;
                                obj.siblings('em').html(num);
                           }else if(respones.error==3){
                                
                                 layer.msg(respones.info, {icon: 5},function(){});
                                // obj.html("点赞");
                                 num = parseInt(obj.siblings('em').html())-1;
                                 obj.siblings('em').html(num);
                                 obj.removeClass('zanok');
                           }else if(respones.error==1){
                                layer.msg(respones.info, {icon: 5},function(){});
                           };
                })
                .fail(function() {
                    console.log("error");
                })
              
                
            });
            //回复某人
            $('.reply').click(function(event) {
                obj = $(this);
                nickname = obj.attr('nickname');
                str = "@"+nickname+'@';
                content= layedit.getContent(index);
                if (content.indexOf(str)=='-1') {
                    console.log(content.indexOf(str));
                    str = content+str;
                    layedit.setContent(index,str);
                    layedit.xbsfocus(index);
                };
            });




                  
      
        });

   
    
        </script>
       